<!DOCTYPE html>
<html class="x-admin-sm">
  <head>
    <meta charset="UTF-8">
    <title></title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width,height=device-height,initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no">
    <link rel="stylesheet" href="__ADMIN__/css/font.css">
    <link rel="stylesheet" href="__ADMIN__/css/xadmin.css">
    <script type="text/javascript" src="__ADMIN__/js/jquery.min.js"></script>
    <script type="text/javascript" src="__ADMIN__/lib/layui/layui.js" charset="utf-8"></script>
    <script type="text/javascript" src="__ADMIN__/js/xadmin.js"></script>
    <script type="text/javascript" src="__ADMIN__/js/cookie.js"></script>
    <link rel="stylesheet" href="/static/admin/css/font.css">
    <link rel="stylesheet" href="/static/admin/css/font-awesome.min.css">
    <style>
        .layui-form-item .layui-form-label{
            width: 120px;
        }
        .layui-form-item .layui-textarea{
            width: 190px;
        }
        #phone-one-div {display: none}
    </style>
  </head>
  
  <body>
    <div class="x-body">
        <form class="layui-form">
          <div class="layui-form-item">
              <label for="activity" class="layui-form-label">
                  <span class="x-red">*</span>礼品名称
              </label>
              <div class="layui-input-inline">
                  <input type="text" value="{$info.goods_name}" id="goods_name" name="goods_name" lay-verify="required" required="" autocomplete="off" class="layui-input">
              </div>
          </div>
          <div class="layui-form-item">
              <label for="name" class="layui-form-label">
                  品牌
              </label>
              <div class="layui-input-inline">
                  <input type="text" value="{$info.brand}" id="brand" name="brand"  autocomplete="off" class="layui-input">
              </div>
          </div>
          <div class="layui-form-item">
              <label for="name" class="layui-form-label">
                  底价
              </label>
              <div class="layui-input-inline">
                  <input type="number" value="{$info.real_price|default='0'}"  min="0" id="real_price" name="real_price"  autocomplete="off" class="layui-input">
              </div>
          </div>
          <div class="layui-form-item">
              <label for="name" class="layui-form-label">
                  京东价
              </label>
              <div class="layui-input-inline">
                  <input type="number" value="{$info.jd_price|default='0'}" min="0" id="jd_price" name="jd_price"  autocomplete="off" class="layui-input">
              </div>
          </div>
          <div class="layui-form-item">
              <label for="name" class="layui-form-label">
                  累计库存
              </label>
              <div class="layui-input-inline">
                  <input type="number" value="{$info.goods_count|default='0'}" id="goods_count" name="goods_count" readonly autocomplete="off" class="layui-input">
              </div>
          </div>
          <div class="layui-form-item">
              <label for="name" class="layui-form-label">
                  预览图
              </label>
              <div class="layui-input-inline">
                <input type="text" value="{$info.thumbnail}" id="thumbnail" name="thumbnail"  autocomplete="off" class="layui-input">
                <button type="button" style="width: 140px;" class="layui-btn layui-btn-sm layui-btn-normal" id="uploads_"><i class="layui-icon">&#xe67c;</i>上传图片</button>
                <img id="img_" src="{$info.thumbnail}" width="140px" style="margin-top: 5px;display: block;">
              </div>
          </div>
          <div class="layui-form-item">
              <label for="name" class="layui-form-label">
                  电商地址
              </label>
              <div class="layui-input-inline">
                  <input type="text" value="{$info.jd_url}" id="jd_url" name="jd_url"  autocomplete="off" class="layui-input">
              </div>
          </div>
          
          
          <div class="layui-form-item">
              <label for="note" class="layui-form-label">
                  状态
              </label>
              <div class="layui-input-inline">
                  <select name="status">
                    <option value="0" {if condition="$info.status == 0"}selected{/if}>停用</option>
                    <option value="1" {if condition="$info.status == 1"}selected{/if}>启用</option>
                  </select>
              </div>
          </div>
          
          <div class="layui-form-item">
              <label for="L_repass" class="layui-form-label">
              </label>
              <button type="button" class="layui-btn" lay-filter="add" lay-submit="">
                  确定
              </button>
          </div>
      </form>
    </div>

    <script>
        layui.use(['form','layer','laydate','upload'], function(){
          $ = layui.jquery;
          var form = layui.form
          ,layer = layui.layer
          ,laydate = layui.laydate
          ,upload = layui.upload;

          var uploadInst = upload.render({
              elem: '#uploads_'
              , url: '{:url("Client/upload")}'
              , before: function (obj) {
                //预读本地文件示例，不支持ie8
                obj.preview(function (index, file, result){
                    //如果有图片再点击上传就撤销原来的图片
                    var img=$("#img_").attr("src");
                    var imgurl=$("#chat_img").val();
                    if(img){
                        $.ajax({
                            type:"post",
                            dataType:"json",
                            data:{imgurl:imgurl},
                            url:"{:url('Client/cancel')}",
                            success:function(data){
                            }
                        });
                    }
                    $('#img_').attr('src', result); //图片链接(base64)
                });
              }
              , done: function (res) {
                  //如果上传失败
                  if (res.code == 0) {
                      return layer.msg(res.err);
                  }
                  //上传成功
                  if(res.code == 1) {
                      $('#img_').attr('src','/uploads/hetong/'+res.savename);
                      $('#thumbnail').attr('value','/uploads/hetong/'+res.savename);
                  }
              }
          });
          //监听提交
          form.on('submit(add)', function(data){

            
            $.ajax({
                type:'POST',
                dataType:'json',
                data:{data:data.field},
                success:function(obj){
                      layer.alert(obj.msg, {icon: obj.icon},function(){
                        // 获得frame索引
                        var index = parent.layer.getFrameIndex(window.name);
                        //关闭当前frame
                        parent.layer.close(index);
                        // 可以对父窗口进行刷新 
                        x_admin_father_reload();
                      });    
                }
            });
            return false;
          });
          
          
        });
    </script>
  </body>

</html>